<!DOCTYPE html>
<html>
<head>
<title>工作计划</title>
<#assign ctx=request.contextPath>
<link rel="shortcut icon" href="${ctx}/images/logo/logo.ico" />
<link rel="Bookmark" href="${ctx}/images/logo/logo.ico" />
<script type="text/javascript" src="${ctx}/js/jquery/jquery-1.11.0.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.form.js"></script>

<script type="text/javascript" src="${ctx}/js/jquery/jquery-migrate-1.2.1.js"></script>
<!-- 导入tinymce 编辑器 -->
<script type="text/javascript" src="${ctx}/js/tiny_mce/tiny_mce.js"></script>
<!-- 导入时间控件My97 -->
<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
</head>
<script type="text/javascript">

tinyMCE.init({
	mode : "exact", // mode:指定附加的模式 textareas : html页面上所有的textarea元素都附加上.
	elements : "work", // exact:精确的模式， 需要指定html元素id属性值
	theme : "advanced", // 主题：advanced(高级的) 、simple(简单的)
	language : "zh-cn", // 国际化
	/** 指定工具按钮资源文件存放的文件夹 */
	plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
	/** 指定工具按钮在上面放四排 */
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
	
	/** 指定工具按钮上下的位置 top、bottom */
	theme_advanced_toolbar_location : "top",
	/** 指定工具按钮左、中、右显示的位置 left、center、right */
	theme_advanced_toolbar_align : "left",
	/** 指定状态栏的位置 (top、bottom) */
	theme_advanced_statusbar_location : "bottom",
	/** 指定编辑器是否可以拖动 */
	theme_advanced_resizing : true
   });

	//关闭当前窗口
	function returnBack() {
		window.opener.location.href=window.opener.location.href;
		self.close();
	}

	$(function(){
		$("#form1").validate({   //绑定一个表单进行验证
		       rules:{ //在这里定义规则
		               'workName' : { required:true,minlength:2},//绑定id 规定必填和最小长度为2
		               'work' :{required:true},//绑定id 规定必填和最小长度为2
		               'sdate' :{required:true},//绑定id 规定必填和最小长度为2
		               'edate' :{required:true},//绑定id 规定必填和最小长度为2
		              },
		       messages : { //信息提示
		    	   workName:{required:"机构名称不能为空!",minlength:"最少2个字符"},//那里不满足规则就提示什么
		    	    work:{required:"机构名称不能为空!"}, //那里不满足规则就提示什么
		    	   sdate:{required:"机构名称不能为空!"},//那里不满足规则就提示什么
		    	   edate:{required:"机构名称不能为空!"},//那里不满足规则就提示什么
		              },
		       submitHandler:function(form){ //当满足上面所有条件之后执行以下函数  form表示上面绑定的表	单
		   			var url = "${ctx}/work/ajaxUpdateWork";
		   			var workId = $("#workId").val();
		   			var userId = $("#userId").val();
		   			var orgId = $("#orgId").val();
		   			var workName = $("#workName").val();
		   			var work = tinyMCE.get('work').getContent();
		   			var planStartDate = $("#sdate").val();
		   			var planEndDate = $("#edate").val();
		   			var params = {"workId":workId,"userId":userId,"orgId":orgId,
		   					"workName":workName,"work":work,
		   					"planStartDate":planStartDate,"planEndDate":planEndDate};
		   			$.post(url,params,function(flag){
		   					if(flag){
		   						alert("更新成功");
		   			}else{
		   				alert("更新失败");
		   			}
		   		},"json");	
		   	}
		});
	});
		
		

		
</script>
<body>
	<form id="form1" name="form1" method="post">
	<#if work??>
		<input type="hidden" name="workId" id="workId" value="${work.workId}"/>
		<input type="hidden" name="userId" id="userId" value="${work.userId}"/>
		<input type="hidden" name="orgId" id="orgId" value="${work.orgId}"/>
		<p>&nbsp;</p>
		<table>
			<tr>
				<td>工作标题:</td>
				<td><label for="textfield3"></label>
				<input type="text" name="workName" value="${work.workName}" id="workName" /></td>
			</tr>
			<tr>
				<td>工作内容:</td>
				<td><label for="textarea"></label> 
				<textarea name="work" id="work" cols="40" rows="7">${work.work}</textarea></td>
			</tr>
			<tr>
				<td>计划开始时间:</td>
				<td><label for=""></label>
					<input id="sdate" class="Wdate"  name="planStartDate" value="${work.planStartDate}" 
					onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:false,maxDate:'#F{$dp.$D(\'edate\')}'});"/>  
				</td>
			</tr>
			<tr> 
				<td>计划完成时间:</td>
				<td><label for="work."></label>
				<input id="edate" class="Wdate"  name="planEndDate" value="${work.planEndDate}" 
				onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,minDate:'#F{$dp.$D(\'sdate\',{d:+1})}'});"/>  
			</td>
			</tr>
		</#if>
		</table>
		<p>&nbsp;</p>
		<input type="submit"  value="更&nbsp;新" /> 
		<input type="button" onclick="returnBack()" value=" 关  闭 "/>
	</form>
</body>
</html>
